package com.seven.commons;


import java.util.Optional;
import java.util.function.Supplier;

/**
 * @projectname:common-utils
 * @author: sevenDay
 * @date: 2019/8/12 17:37
 * @desc: jdk8的新特性
 */
public class OptionalUtils {

    public static <T> Optional<T> resolve (Supplier<T> resolver){
        try {
            T result = resolver.get();

            return Optional.ofNullable(result
                                            );
        }catch (NullPointerException e){
            // 可能会抛出空指针异常，直接返回一个空的 Optional 对象
            return Optional.empty();
        }
    }
    public static <T,R> R  resolveApply (T t,Supplier<T> resolver){

        return null;
    }


    public static void main(String[] args) {
    }
}
